package com.yanqu.road.server.cmd.activity.cat;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.CatProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.cat.CatMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_CAT_DRAW_NOTICE, desc = "抽奖公告")
public class GetCatDrawNoticeCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {

        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ActivityInfo activityInfo = CatMgr.getActivityInfo();
        if (!ActivityMgr.activityInShowTime(activityInfo)) {
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }
        CatProto.CrossGetCatNoticeReqMsg.Builder builder = CatProto.CrossGetCatNoticeReqMsg.newBuilder();
        builder.setActivityId(activityInfo.getActivityId());
        builder.setServerId(player.getUserInfo().getOriginalServerId());
        player.sendPacket(Protocol.C_CAT_ACTIVITY_GET_NOTICE, builder);

    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            CatProto.GetCatNoticeRespMsg.Builder builder = CatProto.GetCatNoticeRespMsg.newBuilder();
            builder.setRet(ret);
            player.sendPacket(Protocol.U_CAT_DRAW_NOTICE, builder);
        }
    }
}
